package com.cmas.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cmas.common.core.domain.entity.SysDept;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 部门管理 数据层
 *
 * @author cmas
 */
public interface SysDeptMapper extends BaseMapper<SysDept> {

    /**
     * 根据角色ID查询部门树信息
     *
     * @param roleId            角色ID
     * @param deptCheckStrictly 部门树选择项是否关联显示
     * @return 选中部门列表
     */
    public List<Integer> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly);

    /**
     *  获取祖节点id
     * @param deptId
     * @return
     */
    @Select("SELECT ancestors FROM sys_dept where dept_id = #{deptId}")
    String selectParentIds(Long deptId);

    /**
     * selectOrganize
     * @param deptIds
     */
    List<SysDept> selectOrganize(@Param("deptIds") String[] deptIds);

    /**
     * selectParentNode
     * @param deptId
     * @return
     */
    List<SysDept> selectParentNode(@Param("deptId") Long deptId);

    @Select("select count(*) from sys_dept where dept_type = '2' and del_flag = '0'")
    Integer collegeCount();

    String selectColleg(Long aLong);
}
